<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*,java.io.*,java.sql.*,InvestmentPojo.*,ImmovableIndia.*;;"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Borrowing In Rupees</title>
</head>
<%!
ConnectionPool pool=null;
public Connection getConnection() throws SQLException, Exception {
	pool=new ConnectionPool();
	return pool.getConnection();
}
%>
<% 
List optionsList123=new ArrayList();
Connection con=null;
Statement st=null;
ResultSet rs=null;
String optionvalue="";
try{
	con=getConnection();
	st=con.createStatement();
	rs=st.executeQuery("select * from investment_in_india where form_id = 8 order by option_label");
	while(rs.next()){
		OptionsList obj = new OptionsList();
		obj.setOptionId(rs.getString(1));
		obj.setListTypeId(rs.getString(2));
		obj.setOptionLabel(rs.getString(3));
		obj.setOptionValue(rs.getString(4));
		obj.setQestFlag(rs.getString(7));
		obj.setShowFlag(rs.getString(8));
		optionsList123.add(obj);
	}
}catch(Exception e ){
	e.printStackTrace();
}finally{
	try {
		if(null != rs)
			pool.releaseResources(rs);
		System.out.println("Connection RS closed........--------------");
		if(null != st)
			pool.releaseResources(st);
		System.out.println("Connection ST closed........--------------");
		if(null != con)
		pool.releaseConnection(con);
		System.out.println("Connection con closed........--------------");
	} catch (Exception e) {
		e.printStackTrace();
	}
}
%>

<script>
function loadSectorDropDown()
{
	var selectedValue ='';
	var selectedInvestor ='';
	var radios ='';
	
	radios = document.getElementsByName("entity");		
	for(var i = 0; i < radios.length; i++) {
	    if(radios[i].checked) selectedValue = radios[i].value;  
	} 	
	radios = document.getElementsByName("investor");
	for(var i = 0; i < radios.length; i++) {
	    if(radios[i].checked) selectedInvestor = radios[i].value;  
	}
	//alert("selected value..."+selectedValue);
	var xmlhttp;
	if (window.XMLHttpRequest)
	  {
		// code for IE7+, Firefox, Chrome, Opera, Safari
	   xmlhttp=new XMLHttpRequest();
	  }
	else
	  {
		// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	     {
		  document.getElementById("TR04").innerHTML = "";
	     document.getElementById("TR04").innerHTML= xmlhttp.responseText;
 	    }
	  }
	xmlhttp.open("GET","dropDownAction.do?key="+selectedValue+"&invkey="+selectedInvestor,true);
	xmlhttp.send();
	selectedValue = '';
}
function loadFormToSubmit()
{

	var selectedValue ='';
	var sectorId = '';
	var subsectorId = '';
	var borrower = getSelectedRadiosValue("borrower");
	var residentperson = getSelectedRadiosValue("residentperson");
	var repat = getSelectedRadiosValue("repat");
	var formofloan = getSelectedRadiosValue("formofloan");
	    if(borrower != "" && null != borrower){ 
	    	selectedValue = borrower;  
	}
	    if(residentperson != "" && null != residentperson){ 
	    	selectedValue = selectedValue+'.'+residentperson;  
	}
	    if(repat != "" && null != repat){ 
	    	selectedValue = selectedValue+'.'+repat;  
	}
	    if(formofloan != "" && null != formofloan){ 
	    	selectedValue = selectedValue+'.'+formofloan;  
	}	
	//alert("selected value = "+selectedValue);
	//document.getElementById("selected").innerHTML="Selected Key - "+selectedValue;
	var xmlhttp;
	if (window.XMLHttpRequest)
	  {
		// code for IE7+, Firefox, Chrome, Opera, Safari
	   xmlhttp=new XMLHttpRequest();
	  }
	else
	  {
		// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	     {
		document.getElementById("myDiv").innerHTML='';
		cache: false;
	    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
	    cache: false;
	    }
	  }
	xmlhttp.open("GET","investorAction.do?key="+selectedValue+"&formId="+8,true);
	xmlhttp.send();
	selectedValue = '';
}
function radioUncheckFun(radiosname){
	//document.getElementById("selected").style.display="none";
	var radList = document.getElementsByName(radiosname);
	if(null != radList){
	 for (var i = 0; i < radList.length; i++) {
	 if(radList[i].checked) radList[i].checked = false;
	 }
}}
function getSelectedRadiosValue(NameofRadios){
	//document.getElementById("selected").style.display="none";
	var selectedRadioValue='';
	var radList = document.getElementsByName(NameofRadios);
	if(null != radList){
	 for (var i = 0; i < radList.length; i++) {
	 if(radList[i].checked) selectedRadioValue = radList[i].value;
	 }
	 return selectedRadioValue;
   }
}
function goForConclution(){
	loadFormToSubmit();
	document.getElementById("Answers").style.display="";
	//document.getElementById("selected").style.display="";
	document.getElementById("myDiv").innerHTML="<img alt='Plz wait...' src='loading9.gif' width='30'/>&nbsp;&nbsp;Plz wait...while loading...";
}
function setVisibilityArr(varArray,visibility){
    if(null != varArray){
        for(i = 0; i < varArray.length; i++){
            var tdvar = varArray[i];
            if(tdvar != null){
            tdvar.style.display=visibility;
            }
        }
    }
 }

function onClickBrrower(){
	var selectedRadioValue='';
	document.getElementById("Answers").style.display="none";
	setVisibilityArr([table1,table2,table3],"none")
	onClickToShow1();
	var selectedRadioValue = getSelectedRadiosValue("borrower");
	 <% if(optionsList123 != null){
			for(int i=0;i<optionsList123.size();i++){
			OptionsList obj1 =(OptionsList)optionsList123.get(i); 
			if(obj1.getListTypeId() != null && obj1.getListTypeId().equals("80") && obj1.getShowFlag().equals("Y")){
				String abc = (String)obj1.getOptionValue();
				%>
				if(selectedRadioValue == '<%=abc%>'){
					document.getElementById('litag'+selectedRadioValue).style.display="";
					document.getElementById('quest').style.display="";
					document.getElementById("table1").style.display="";
				}else{
					document.getElementById('litag<%=abc%>').style.display="none";
				}
				<%
					}
				}
			}
			%>
			if(selectedRadioValue != "1"){
				document.getElementById('litag7').style.display="none";
			}else
				document.getElementById('litag7').style.display="";
}
function onClickResidentPerson(){
	var selectedRadioValue=''; radioUncheckFun("repat");
	document.getElementById("Answers").style.display="none";
	document.getElementById("table2").style.display="none";
	document.getElementById("table3").style.display="none";
	document.getElementById('submitbutton').style.display="none";
	var selectedRadioValue = getSelectedRadiosValue("residentperson");
		   <% if(optionsList123 != null){
	for(int i=0;i<optionsList123.size();i++){
	OptionsList obj1 =(OptionsList)optionsList123.get(i); 
	if(obj1.getListTypeId() != null && obj1.getListTypeId().equals("81") && obj1.getShowFlag().equals("Y")){
		String abc = (String)obj1.getOptionValue();
		%>
		if(selectedRadioValue == '<%=abc%>'){
			document.getElementById('litag'+selectedRadioValue).style.display="";
			document.getElementById('residentone').style.display="";
			document.getElementById("table2").style.display="";
		}else{
			document.getElementById('litag<%=abc%>').style.display="none";
		}
		<%
			}
		}
	}
	%>
	/* if(selectedRadioValue == "3"){
		document.getElementById('litag8').style.display="none";
	}else if(selectedRadioValue == "4"){
		document.getElementById('litag8').style.display="none";
		document.getElementById("litag9").style.display="none";
	}else{
		document.getElementById('litag6').style.display="none";
		document.getElementById('litag7').style.display="none";
		document.getElementById("litag9").style.display="none";
	} */
	   }
function onClickRepatriation(){
	document.getElementById("table3").style.display="none";
	radioUncheckFun("formofloan"); onClickToShow2();
	var repyes=document.getElementById("repyes");
	 var repno=document.getElementById("repno");
	 var selectedRadioValue = getSelectedRadiosValue("borrower");
	 if(repyes.checked){
	    	 document.getElementById("Answers").style.display="none";
	    	 document.getElementById("submitbutton").style.display="";
	     }
	 if(repno.checked){
	    	 document.getElementById("Answers").style.display="none";
	    	 document.getElementById("submitbutton").style.display="";
	    	 if(selectedRadioValue == "2"){
	    	 document.getElementById("table3").style.display="";
	    	 document.getElementById("submitbutton").style.display="none";
	    	 }
	 }
}
function onClickFormOfLoan(){
	var selectedRadioValue='';
	document.getElementById('submitbutton').style.display="none";
	document.getElementById("Answers").style.display="none";
	var selectedRadioValue = getSelectedRadiosValue("formofloan");
		   <% if(optionsList123 != null){
	for(int i=0;i<optionsList123.size();i++){
	OptionsList obj1 =(OptionsList)optionsList123.get(i); 
	if(obj1.getListTypeId() != null && obj1.getListTypeId().equals("82") && obj1.getShowFlag().equals("Y")){
		String abc = (String)obj1.getOptionValue();
		%>
		if(selectedRadioValue == '<%=abc%>'){
			document.getElementById('litag'+selectedRadioValue).style.display="";
			document.getElementById('questd').style.display="";
			document.getElementById('submitbutton').style.display="";
		}else{
			document.getElementById('litag<%=abc%>').style.display="none";
		}
		<%
			}
		}
	}
	%>	
}
function onClickToShow(){
	radioUncheckFun("repat"); onClickToShow1();
	radioUncheckFun("borrower");
	document.getElementById("Answers").style.display="none";
	document.getElementById('quest').style.display="none";
	document.getElementById('submitbutton').style.display="none";
	document.getElementById("table1").style.display="none";
	document.getElementById("table2").style.display="none";
	document.getElementById("table3").style.display="none";
	for(var i=1;i<=4;i++){
		document.getElementById('litag'+i).style.display="";
	}
}
function onClickToShow1(){
	radioUncheckFun("repat");onClickToShow2();
	radioUncheckFun("residentperson");
	document.getElementById("Answers").style.display="none";
	document.getElementById('residentone').style.display="none";
	document.getElementById('submitbutton').style.display="none";
	document.getElementById("table2").style.display="none";
	document.getElementById("table3").style.display="none";
	var selectedRadioValue = getSelectedRadiosValue("borrower");
	for(var i=5;i<=7;i++){
		document.getElementById('litag'+i).style.display="";
	}
	if(selectedRadioValue != "1"){
		document.getElementById('litag7').style.display="none";
	}else
		document.getElementById('litag7').style.display="";
}
function onClickToShow2(){
	radioUncheckFun("formofloan");
	document.getElementById("Answers").style.display="none";
	document.getElementById('questd').style.display="none";
	document.getElementById('submitbutton').style.display="none";
	var selectedRadioValue = getSelectedRadiosValue("residentperson");
		if(selectedRadioValue == "5" || selectedRadioValue == "6"){
		document.getElementById("litag8").style.display="";
		document.getElementById("litag9").style.display="";
	/* }else if(selectedRadioValue == "4"){
		document.getElementById("litag6").style.display="";
		document.getElementById("litag7").style.display="";
	}else{
		document.getElementById("litag8").style.display=""; */
	}
}
</script>

<body bgcolor="">
	<form name="frm" method="post">
		<table width="730" align="center" border="0" cellspacing="0"
			cellpadding="0" valign="middle">
			<input type="hidden" name="formId" value="8" />
			<tr>
				<td>&nbsp;</td>
			</tr>
		</table>
		<table width="730" align="center" class="TBFORM" border="0"
			cellspacing="0" cellpadding="0" valign="middle">

			<tr>
				<td align="center" height="10" class="TITLEFORM">Borrowing In Rupees Tool</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td width="730" style="padding-left:10px">
					<table width="700" align="center" class="TDBBLRFORM" border="0"
						cellspacing="0" cellpadding="0">
						<tr>
							<td class="testform" width="704" id=""><b>Type of Borrower</b>
								&nbsp;<a class="anchor" style="display: none;" id="quest"
								href="javascript:onClickToShow()" value="show all" align="right">show
									all</a></td>
						</tr>
					</table>
					<table width="707" align="center" class="TDBBLRFORM" border="0"
						cellspacing="0" cellpadding="0">

						<% if(optionsList123 != null){
	
	//System.out.print(optionsList123.size());
	for(int i=0;i<optionsList123.size();i++){
		
	OptionsList obj =(OptionsList)optionsList123.get(i); 
	if(obj.getListTypeId() != null && obj.getListTypeId().equals("80") && obj.getShowFlag().equals("Y")){
		//System.out.println("============================"+i);
	%>
						<tr id="litag<%=obj.getOptionValue()%>">
							<td width="20" valign="top"><input type="radio"
								name="borrower" id="<%=obj.getOptionId()%>"
								value="<%= obj.getOptionValue()%>"
								onclick="onClickBrrower()" /></td>
							<td width="680" valign="top"><font><label
										for="<%=obj.getOptionId()%>"><%= obj.getOptionLabel()%></label></font></td>
						</tr>
						<%	
	}
	}	  		
	
} %>
					</table>
					<div id="table1" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
						</table>
						<table width="700" align="center" class="TDBBLRFORM" border="0"
							cellspacing="0" cellpadding="0">
							<tr>
								<td colspan="2" class="testform" width="704" id=""><b>Type of person resident outside India</b>&nbsp;<a class="anchor" style="display: none;" id="residentone"
									href="javascript:onClickToShow1()" value="show" align="right">show
										all</a></td>
							</tr>
						</table>
						<table width="707" align="center" class="TDBBLRFORM" border="0"
							cellspacing="0" cellpadding="0">

							<% if(optionsList123 != null){
	
	//System.out.print(optionsList123.size());
	for(int i=0;i<optionsList123.size();i++){
		
	OptionsList obj =(OptionsList)optionsList123.get(i); 
	if(obj.getListTypeId() != null && obj.getListTypeId().equals("81") && obj.getShowFlag().equals("Y")){
		//System.out.println("============================"+i);
	%>
							<tr id="litag<%=obj.getOptionValue()%>">
								<td width="20" valign="top"><input type="radio"
									name="residentperson" id="<%=obj.getOptionId()%>"
									value="<%= obj.getOptionValue()%>"
									onclick="onClickResidentPerson()" /></td>
								<td width="680" valign="top"><font><label
											for="<%=obj.getOptionId()%>"><%= obj.getOptionLabel()%></label></font></td>
							</tr>
							<%	
	//System.out.println(obj.getListTypeId()+"  treeeeeeeeeeeeeeeeeeeeeeeee   "+obj.getOptionLabel()+"  " );
	}
	}	  		
	
} %>
						</table>

					</div>
					<div id="table2" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
						</table>
						<table width="710" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr class="testform">
								<td width="200"><b>Mode of repatriation&nbsp;</b></td>
								<td width="600"><b><label for="repyes"><input
											type="radio" value="Y" name="repat" id="repyes"
											onClick="onClickRepatriation()">&nbsp;<u title="Sale proceeds and dividend net of taxes is eligible to be taken back from India.">Repatriation ?</u>&nbsp;&nbsp;</label><label
										for="repno"><input type="radio" value="N" name="repat"
											id="repno" onClick="onClickRepatriation()">&nbsp;<u title="Sale proceeds and dividend net of taxes is not eligible to be taken back from India.">Non Repatriation ?</u></b></td>
							</tr>
						</table>

					</div>
					<div id="table3" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
						</table>
						<table width="700" align="center" class="TDBBLRFORM" border="0"
							cellspacing="0" cellpadding="0">
							<tr>
								<td colspan="2" class="testform" width="704" id=""><b>Form of Loan</b>&nbsp;<a class="anchor" style="display: none;" id="questd"
									href="javascript:onClickToShow2()" value="show" align="right">show
										all</a></td>
							</tr>
						</table>
						<table width="707" align="center" class="TDBBLRFORM" border="0"
							cellspacing="0" cellpadding="0">

							<% if(optionsList123 != null){
	
							for(int i=0;i<optionsList123.size();i++){
		
							OptionsList obj =(OptionsList)optionsList123.get(i); 
							if(obj.getListTypeId() != null && obj.getListTypeId().equals("82") && obj.getShowFlag().equals("Y")){
							%>
							<tr id="litag<%=obj.getOptionValue()%>">
								<td width="20" valign="top"><input type="radio"
									name="formofloan" id="<%=obj.getOptionId()%>"
									value="<%= obj.getOptionValue()%>"
									onclick="onClickFormOfLoan()" /></td>
								<td width="680" valign="top"><font><label
											for="<%=obj.getOptionId()%>"><%= obj.getOptionLabel()%></label></font></td>
							</tr>
							<%	
								}
								}	  		
	
							} %>
						</table>

					</div>
					<div id="submitbutton" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
							<tr align="center">
								<td><a class="anchor" align="center" id="finalanswer"
									href="javascript:goForConclution()" value="">Go For
										Conclusion</a></td>
							</tr>
							<!-- <tr>
								<td id="selected" style="display: none;"></td>
							</tr> -->
						</table>
					</div>
					</div>
					<div id="Answers" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
						</table>

						<table width="700" align="center" class="TBFORM" border="0"
							cellspacing="0" cellpadding="0" valign="middle">
							<tr>
								<td class="testform" width="704" callspan="1" align="left"><font size=2><b>Know Eligibility with Allied Conditions</font></b></td>
							</tr>
							<tr>
								<td id="myDiv" align="center"></td>
							</tr>
						</table>
					</div>
			<tr>
				<td>&nbsp;</td>
			</tr>
			</td>
			</tr>
		</table>
		<table width="700" align="center" border="0" cellspacing="0"
			cellpadding="0" valign="middle">
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
		</table>

	</form>
</body>
<script>
radioUncheckFun("borrower");
radioUncheckFun("residentperson");
radioUncheckFun("repat");
radioUncheckFun("formofloan");
</script>
</html>